snippet if "if-else"
if [ ${1:command} ] 
then 
	$2
fi
endsnippet

snippet else "else "
${1:else/elif} [ ${2:command} ] 
then 
	$3
endsnippet

snippet for "for loop"
for ${1:var} in ${2:list}
do 
	$3
done
endsnippet

snippet while  "while loop"
while [ ${1:command} ]
do 
	$2
done
endsnippet

snippet case "case"
case ${1:var} in
	${2:pat1 | pat2})
		$3
		;;
	*)
		$6
		;;
esac
endsnippet

snippet math "execute math"
\$[${1:\$var1 * \$var2}]
endsnippet

snippet test1 "compare number"
[ v1 -${1:eq/ge/gt/le/lt/ne} v2 ]
endsnippet

snippet test2 "compare string"
[ s1 ${1:=/!=/</>/-n/-z} s2 ]
endsnippet

snippet test3 "compare file"
# -d file, 检查file是否存在并且是一个目录
# -e file, 检查file是否存在
# -f file, 检查file是否存在并且是一个文件
# -r file, 检查file是否存在并且可读
# -s file, 检查file是否存在并且不为空
# -w file, 检查file是否存在并且可写
# -x file, 检查file是否存在并且可执行
if [ -${1:d} file ]
then
	$2
fi
endsnippet

snippet string_is_zero "string length is equal 0, true"
if [ -z "`grep 'select' test.lua`" ] then
	$1
fi
endsnippet

snippet string_not_zero "string length is great then 0, true"
if [ -n "`grep 'select' test.lua`" ] then
	$1
fi
endsnippet


snippet file_exists "Check if File Exists"
# -a if file exists, retrun true
# -d if directory exists, return true
# -e if file of directory exists, return true
if [ -a ${1:name} ] then
	$2
fi
endsnippet

